#include <iostream> 
#include "people.pb.h" // 引⼊编译⽣成的头⽂件
using namespace std; 
 
int main() 
{ 
     string people_str; 
     People people; 
     people.set_age(20); 
     people.set_name("tom");
     // 调⽤序列化⽅法，将序列化后的⼆进制序列存⼊string中
     if (!people.SerializeToString(&people_str))
         cout << "序列化联系⼈失败." << endl; 
     People people2; 
     // 调⽤反序列化⽅法，读取string中存放的⼆进制序列，并反序列化出对象
     if (!people2.ParseFromString(people_str))
         cout << "反序列化出联系⼈失败." << endl;
     cout << people2.name() << endl;
     cout << people2.age() << endl;

}
